<template>
  <!-- 弹框-->
  <a-modal
    :title="auditStatus.status == false ? '请输入驳回理由' : '确认同意'"
    :visible="visible"
    @cancel="clickCancel()"
    @ok="clickConfirm()"
    width="50%"
    :confirmLoading="confirmLoading"
  >
    <a-form-model
      v-if="auditStatus.status == false"
      ref="ruleForm"
      :rules="rules"
      :model="form"
      :wrapper-col="wrapperCol"
      labelAlign="left"
    >
      <a-form-model-item prop="cName">
        <a-input v-model="form.cName" type="textarea" />
      </a-form-model-item>
    </a-form-model>
    <a-descriptions v-if="auditStatus.status == true" :title="auditStatus.applyReason">
      <a-descriptions-item label="收款人">{{ auditStatus.userName }}</a-descriptions-item>
      <a-descriptions-item label="申请金额">{{ auditStatus.totalAmount | formatAmount }}</a-descriptions-item>
    </a-descriptions>
  </a-modal>
</template>
<script>
export default {
  props: {
    visible: {
      default: false,
      type: Boolean
    },
    auditStatus: {
      type: Object,
      default () {
        return {}
      }
    }
  },
  data () {
    return {
      wrapperCol: { span: 24 },
      confirmLoading: false,
      rules: {
        // 校验规则
        cName: [{ required: true, message: '请输入驳回理由' }]
      },
      form: {}
    }
  },
  mounted () {},
  watch: {},
  methods: {
    clickCancel () {
      this.form = this.$options.data().form
      this.$emit('uploadModalCancel')
    },
    clickConfirm () {
      if (!this.auditStatus.status && (this.form.cName === null || this.form.cName === '' || this.form.cName === undefined)) {
        this.$message.error('请填写驳回理由')
        return false
      }
      const forms = { ...this.auditStatus, refuseReason: this.form.cName }
      this.$emit('uploadClickConfirm', forms)
    }
  }
}
</script>
